package com.woniuxy.mapper;

import java.util.List;

import org.apache.ibatis.annotations.*;

import com.woniuxy.entity.Address;

@Mapper
public interface AddressMapper {

	@Select("select*from address where u_id=#{u_id}")
	public List<Address> findAddressByUid(int u_id);

	@Select("select*from address where u_id=#{u_id} and type='y'")
	public Address findAddressByUidY(int u_id);

	// 单个设置默认
	@Update("update address set type='y' where a_id=#{a_id}")
	public int updataAddressY(int a_id);

	// 多个设置不默认
	@Update("update address set type='n' where u_id=#{u_id}")
	public int updataAddressN(int u_id);

	@Insert("insert into address values(default,#{u_id},#{accept},#{telphone},#{province},#{city},#{county},#{detailed},#{type})")
	public int addAddress(Address address);

	@Delete("delete from address where a_id=#{a_id}")
	public int delAddress(int a_id);

}
